package sliver.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import sliver.dao.ShopperDao;
import sliver.entity.Shopper;

@Repository
public class ShopperDaoImpl extends BaseDaoImpl<Shopper> implements ShopperDao{

	@Override
	public Shopper findByAuth(String username, String password) {
		
		String queryString = "SELECT shopper " +
							 "FROM Shopper shopper " +
							 "WHERE shopper.username = ? " +
							 "AND shopper.password = ? ";
		
		List<Shopper> shoppers = complexQuery(queryString, new Object[]{username, password});
		
		if(shoppers != null && shoppers.size() > 0)
			return shoppers.get(0);
		
		return null;
	}

}
